/*********************************************************************************
 *FileName:  nsuc16xx_lin.h
 *Version:  V1.0
 *Date: 2023-04-16
 **********************************************************************************/

#ifndef __nsuc16xx_lin_H__
#define __nsuc16xx_lin_H__

/***************************************Includes***********************************/
#include "nsuc16x0.h"

/***************************************Macros***********************************/
#define LINUART_Mode_Normal                     ((uint8_t)0x00)
#define LINUART_Mode_LIN                        ((uint8_t)0x01)

#define LIN_RX_Disable													((uint8_t)0x00)
#define LIN_RX_Enable														((uint8_t)0x01)

#define LIN_AutoShuntDown_Enable								((uint8_t)0x00)
#define LIN_AutoShuntDown_Disable								((uint8_t)0x01)

#define LIN_TimeOut_Disable											((uint8_t)0x00)
#define LIN_TimeOut_Enable											((uint8_t)0x01)

#define LIN_SlewRate_Disable										((uint8_t)0x00)
#define LIN_SlewRate_Enable											((uint8_t)0x01)

#define LIN_TX_UART															((uint8_t)0x00)
#define LIN_TX_PWMIO														((uint8_t)0x01)
#define LIN_TX_TIMER0														((uint8_t)0x02)
#define LIN_TX_LINDO														((uint8_t)0x03)


#define PWMIO_TO_LINRX													((uint8_t)0x00)
#define PWMIO_TO_GPIO														((uint8_t)0x01)

#define UART_TO_LINRX														((uint8_t)0x00)
#define UART_TO_GPIO														((uint8_t)0x01)

#define LIN_OCFT_4us8														((uint8_t)0x00)
#define LIN_OCFT_9us6														((uint8_t)0x01)
#define LIN_OCFT_19us2													((uint8_t)0x02)
#define LIN_OCFT_38us4													((uint8_t)0x03)

#define LIN_RXFT_None														((uint8_t)0x00)
#define LIN_RXFT_0us3														((uint8_t)0x01)
#define LIN_RXFT_0us45													((uint8_t)0x02)
#define LIN_RXFT_0us6														((uint8_t)0x03)
#define LIN_RXFT_0us9														((uint8_t)0x04)
#define LIN_RXFT_1us2														((uint8_t)0x05)
#define LIN_RXFT_1us8														((uint8_t)0x06)
#define LIN_RXFT_2us4														((uint8_t)0x07)
#define LIN_RXFT_3us6														((uint8_t)0x08)
#define LIN_RXFT_4us8														((uint8_t)0x09)
#define LIN_RXFT_7us2														((uint8_t)0x0A)
#define LIN_RXFT_9us6														((uint8_t)0x0B)
#define LIN_RXFT_14us4													((uint8_t)0x0C)
#define LIN_RXFT_19us2													((uint8_t)0x0D)

/***************************************Variables***********************************/
typedef struct
{
    uint8_t LIN_RX_Status;
    uint8_t LIN_UV_AutoShuntDown;
    uint8_t LIN_TX_TimeOut;
    uint8_t LIN_SlewRate;
    uint8_t LIN_TX_OutSource;
    uint8_t PWMIO_Source;
		uint8_t UART_Source;
    uint8_t LIN_RX_UARTMode;
    uint8_t LIN_OCFitlerTime;
    uint8_t LIN_RX_FitlerTime;
		uint8_t LIN_Pu30K_Enable;
}LIN_InitTypeDef;

/***************************************Functions***********************************/
void LIN_Init(LINPORT_TypeDef* LINPORTx, LIN_InitTypeDef* LIN_InitStruct);
void LIN_Cmd(LINPORT_TypeDef* LINPORTx, FunctionalState NewState);
void LINRX_Cmd(LINPORT_TypeDef* LINPORTx, FunctionalState NewState);

#endif
/* [] END OF nsuc16xx_lin.h */
